package com.xinzhi.savingpot.userinfo.controller;

import com.xinzhi.savingpot.userinfo.service.impl.PersonalCenterServiceImpl;
import com.xinzhi.savingpot.util.BaseResponse;
import com.xinzhi.savingpot.vo.PersonalVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/PersonalCenterController")
@Api("个人信息页")
public class PersonalCenterController {

    @Autowired
    PersonalCenterServiceImpl personalCenterService;
    @GetMapping("/personal")
    @ApiOperation("显示查询的信息")
    public String personal(String token){
        return personalCenterService.searchResult(token);
    }
    @GetMapping("/updatePersonal")
    @ApiOperation("修改查询的信息")
    public BaseResponse updatePersonal(String userNickname, String userSex, String userHeadPhoto, String phone, String userId){
        PersonalVo as = new PersonalVo();
/*String token = userId.getHeader("token");
        Claims claims = JwtUtil.checkJWT(token);
        String user = claims.getAudience();*/
        if(userNickname!=null){as.setUserNickName(userNickname);}
        if(userSex!=null){as.setUserSex(userSex);}
        if(userHeadPhoto!=null){as.setUserHeadPhoto(userHeadPhoto);}
        if(phone!=null){as.setPhone(phone);}
        as.setUserId(userId);
        return personalCenterService.updatePersonal(as);
    }
}
